const express = require('express');
let pageRouter = express.Router();
let noteModel =require('../db/model/noteModel');

pageRouter.get('/',(req,res)=>{
    res.redirect('/list');
})

pageRouter.get('/list',(req,res)=>{

    noteModel.find().then(data=>{
        // console.log(data);
        res.render('list.html',{data});
    })
})

pageRouter.get('/addnote',(req,res)=>{
    res.render('addnote.html');
})

pageRouter.get('/updatenote',(req,res)=>{
    let {_id} = req.query;

    noteModel.findById(_id).then(data=>{
        res.render('updatenote.html',{data});
    })
})

module.exports = pageRouter;